package org.blogwu.learn.multithread.chapter3.demo22;

public class Consumer extends Thread {


    @Override
    public void run() {
        while (true) {
            if (Main.arrayBlockingQueue.size() <= 0) {
                synchronized (Main.obj) {
                    Main.obj.notifyAll();
                }

                try {
                    synchronized (Main.obj) {

                        Main.obj.wait();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("消费值：" + Main.arrayBlockingQueue.poll());
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}